//
//  NSString+TDHTML.h
//  BiFrostCoin
//
//  Created by xieShou on 2020/4/13.
//  Copyright © 2020 xichuan. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (TDHTML)
- (NSString *)URLEncodedString;
- (NSString *)encodeUrl;
- (NSString *)urlDecodeString;
+ (NSDate *)dateWithCustomDateFormat:(NSString *)dateStr;
+ (NSString*)getCurrentFormatTimes;
+ (NSString*)getCurrentTime:(NSString *)format;
- (NSString *)getUpdateStringWith:(NSDate *)date;
+ (NSString *)getNowTimeTimestamp;
+ (NSString *)getNowTimeSince;
+ (NSString *)getNowTimeTimeWithHaoMiao;
+ (NSTimeInterval)getIntegerWithTime:(NSString *)times;
+(NSString *)timestampSwitchTime:(NSInteger)timestamp andFormatter:(NSString *)format;

+ (NSString *)convertFileSize:(long long)size;
- (CGFloat)getStringHeightWithText:(NSString *)text font:(UIFont *)font viewWidth:(CGFloat)width;

- (BOOL)isPhoneNumber;
- (BOOL)isTrueUrl;
- (BOOL)checkPassWord;
- (NSString *)unZipHtml;
- (NSString *)zipHtml;

/**
 *   去除空格   \r  \n
 */
- (NSString *)replaceWhitespaceAndNewlineCharacter;
/**
 *   获取是本周 还是更早
 */
+ (NSString *)getThisWeekOrEarlierStringWith:(NSDate *)date;

/**
 *   把时间字符串转换成NSDate
 */
+ (NSDate *)timeFromeString:(NSString *)timeString;

//返回0说明该日期不是今天、昨天、前天
// 返回 1是今天  2是昨天  3是前天
/**
 *   计算  距离现在的时间
 */
+ (NSString *)getUTCFormateDate:(NSDate *)newsDate;

/**
 *   1 代表今天或者昨天  2代表本周  3代表更早
 *   计算距离现在的具体时间段
 */
+ (NSString *)getUTCFormateDate2:(NSDate *)newsDate;

-(NSString *)convertFileSize:(long long)size;

//map转jsonstring
+ (NSString *)convertToJsonData:(NSDictionary *) dict;
//JSON字符串转化为字典
+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;

///字符串是否为空:  空YES  非空NO
+ (BOOL)cy_isEmpty:(NSString *)string;
///字符串转字典
+ (NSDictionary*)cy_stringConversionDictionary:(NSString*)str;

/**
*  设置行间距、字间距和文本颜色
*
*  @param lineSpace 行间距
*  @param kern      字间距
*  @param colorText 设置颜色的文本
*
*  @return 富文本
*/
-(NSMutableAttributedString *)getAttributedStringWithLineSpace:(NSString *) text lineSpace:(CGFloat)lineSpace kern:(CGFloat)kern colorText:(NSString *) colorText;

/**
*  设置行间距和字间距
*
*  @param lineSpace 行间距
*  @param kern      字间距
*
*  @return 富文本
*/
-(NSMutableAttributedString *)getAttributedStringWithLineSpace:(NSString *) text lineSpace:(CGFloat)lineSpace kern:(CGFloat)kern;

///字符串是否为空:  空YES  非空NO
+ (BOOL)zyf_isEmpty:(NSString *)string;

+ (NSString *)flattenHTML:(NSString *)html trimWhiteSpace:(BOOL)trim;

+ (NSDictionary *)convert2DictionaryWithJSONString:(NSString *)jsonString;

/**
 * AES加密
 */
+ (NSString *)aesEncrypt:(NSString *)sourceStr;
 
/**
 * AES解密
 */
+ (NSString *)aesDecrypt:(NSString *)secretStr;


- (NSString *)appendCachePath;

#pragma mark iOS 图片链接含有中文图片无法显示问题解决办法
- (NSString *)stringHaveChinse;


+(NSString *)URLEncodedString2:(NSString *)str;
+(NSString *)URLDecodedString2:(NSString *)str;


//把地址中有中文的编码成UTF8 字符
+ (NSString *)changeUrlStringHaveChineseCharToUTF8String:(NSString *)changeStr;

// 正则匹配是否包含中文
+ (BOOL)validateContainsChinese:(NSString *)content;
// 匹配包含中文：利用rangeOfString:option:直接查找
+ (BOOL)validateRangeContainsChinese:(NSString *)content;

@end
